﻿@{
    ViewBag.Title = "SanThamTheoDanhMuc";
    Layout = "~/Views/Shared/Home/_Layout.cshtml";
}
@using PagedList;
@using PagedList.Mvc
@model IEnumerable<BabyToys.Models.SanPham>

<div class="content">
    <div class="content-left">
        @{Html.RenderAction("ModuleDanhMuc", "Home");}
        <br />
        @RenderPage("~/Views/Shared/Home/_ModuleSanPhamNoiBat.cshtml")
    </div>
    <div class="content-right">
        <div class="list"></div>
        <div style="height:40px;">
            <div style="float:left;width:50%;height:40px;"><h1>Sản phẩm mới</h1></div>    
            <div style="float:right;width:36%;height:30px;margin-top:15px;margin-right:0px;padding-right:0px;">
                    <small style="font-size:12px;">Hiển thị</small> 
                   <select id="HienThi">
                       <option value="5" @if (ViewBag.HienThi == 10)
                                         { @:selected="selected" 
                           }>5</option>
                       <option value="10" @if (ViewBag.HienThi == 10)
                                          { @:selected="selected" 
                           }>10</option>
                       <option value="15" @if (ViewBag.HienThi == 15)
                                          { @:selected="selected" 
                           }>15</option>
                       <option value="20" @if (ViewBag.HienThi == 20)
                                          { @:selected="selected" 
                           }>20</option>
                       <option value="50" @if (ViewBag.HienThi == 50)
                                          { @:selected="selected" 
                           }>50</option>
                   </select>
                 
                   <small style="font-size:12px;">Sắp xếp</small>
                   <select id="SapXep">
                       <option value="0" @if (ViewBag.SapXep == 0)
                                         { @:selected="selected" 
                           }>Mặc định</option>
                       <option value="1" @if (ViewBag.SapXep == 1)
                                         { @:selected="selected" 
                           }>Giá tăng dần</option>
                       <option value="2" @if (ViewBag.SapXep == 2)
                                         { @:selected="selected" 
                           }>Giá giảm dần</option>
                       <option value="3" @if (ViewBag.SapXep == 3)
                                         { @:selected="selected" 
                           }>Tên a đến z</option>
                       <option value="4" @if (ViewBag.SapXep == 4)
                                         { @:selected="selected" 
                           }>Tên z về a</option>
                   </select>
                @{string title = BabyToys.Utilities.EditString.BoDauTrenChuoi(ViewBag.Ten);}
                <script>
                    $("#HienThi").change(function () {
                        var hienthi = $(this).val();
                        window.location.href = 'http://' + window.location.host + '/danh-muc/@ViewBag.Id/@title/?hienthi=' + hienthi+'&sapxep=@ViewBag.SapXep';
                    });
                    $("#SapXep").change(function () {
                        var sapxep = $(this).val();
                        window.location.href = 'http://' + window.location.host + '/danh-muc/@ViewBag.Id/@title/?hienthi=@ViewBag.HienThi&sapxep=' + sapxep;
                    });
                 </script>
            </div>
        </div>
        
        <div class="endtitle"></div>
        <div>
@{PagedList<BabyToys.Models.SanPham> sanphams = ViewBag.onePageOfSanpham;}
@foreach (var sanpham in sanphams)
{
    <div class="box-product">
                <div class="image-product">
                    <img src="~/Content/Images/1355137929_75101-160x160.jpg" />
                </div>
                <div class="name">
                    @{string titlesanpham=BabyToys.Utilities.EditString.BoDauTrenChuoi(sanpham.TenSP);}
                    @Html.ActionLink(sanpham.TenSP,"ChiTiet","SanPham",new{id=sanpham.IdSanPham,slug=titlesanpham},null)
                </div>
                <div class="price">
                    @if (sanpham.GiaKM > 0)
                    {
                        <span class="price-old">@sanpham.Giaban</span>
                        <span class="price-new">@sanpham.GiaKM</span>
                    }
                    else
                    {
                        <span class="price-new">@sanpham.Giaban</span>
                    }
                </div>
                <div class="addcart"><a class="purple button dlLight" href="#">Thêm giỏ hàng</a></div>
            </div>
}
            <div class="clear"></div>
            </div>
            <div style="margin-bottom:0px;">
            @Html.PagedListPager((IPagedList)ViewBag.onePageOfSanPham, page => Url.Action("SanPhamTheoDanhMuc", new { page,hienthi=ViewBag.HienThi,sapxep=ViewBag.SapXep }), PagedListRenderOptions.OnlyShowFivePagesAtATime)
            </div>     
         </div>
    <div class="clear"></div>
    
</div>